package com.googlecode.imanager.jasper.print;

import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.base.JRBasePrintFrame;

import com.googlecode.imanager.jasper.RContainer;
import com.googlecode.imanager.jasper.RControl;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class RFrame extends JRBasePrintFrame implements RChild {

    private static final long serialVersionUID = 1L;

    protected RContainer rOwner;
    protected RInsets insets;
    protected boolean visible;

    public RFrame(RContainer owner) {
        this(owner, null);
    }

    public RFrame(RContainer owner, JRDefaultStyleProvider defaultStyleProvider) {
        super(defaultStyleProvider);
        this.rOwner = owner;
        this.insets = new RInsets();
    }

    public void setDefaultStyleProvider(JRDefaultStyleProvider defaultStyleProvider){
        super.defaultStyleProvider = defaultStyleProvider;
    }
    
    public RContainer getROwner() {
        return rOwner;
    }

    public void setROwner(RControl owner) {
        if (!(owner instanceof RContainer)){
            throw new IllegalArgumentException("owner");
        }
        this.rOwner = (RContainer) owner;
    }

    public RInsets getRInsets() {
        return insets;
    }

    public void setRInsets(RInsets insets) {
        this.insets = insets;
    }

    @Override
    public void destroy() {
        rOwner = null;
    }

    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

}
